package controller;

import java.io.InputStream;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
@Controller
public class UploadController {
	//UPLOADFIVE
		@RequestMapping("Sample/check")
		@ResponseBody
		public String check(HttpServletRequest request){
			Enumeration<String> es=	request.getHeaderNames();
			while (es.hasMoreElements()) {
				String s = (String) es.nextElement();
				System.out.println(s);
			}
		
			
			System.out.println("========================");
			Enumeration<String> es1=	request.getParameterNames();
		while (es1.hasMoreElements()) {
			String s = (String) es1.nextElement();
			System.out.println(s);
		}
			
			return "0";
		}
		
		//UPLOADFIVE
				@RequestMapping("Sample/uploadi5")
				@ResponseBody
				public String uploadifive(@RequestParam(value ="Filedata", required = false) MultipartFile hw,HttpServletRequest request)
				throws Exception
				{

					System.out.println("==========upload==============");
					System.out.println("fileName:...."+hw.getOriginalFilename());
					InputStream in=hw.getInputStream();
					System.out.println("avli...."+in.available());
					Enumeration<String> es1=	request.getParameterNames();
				while (es1.hasMoreElements()) {
					String s = (String) es1.nextElement();
					System.out.println(s);
				}
					
					return "1";
				}
}
